﻿using System;
using System.Collections.Generic;
using MobileWeb.Models;

namespace MobileWeb.Helpers
{
    public class IntervalHelper
    {
        public static List<Area> GetAreas()
        {
            var xmlContent = XmlHelper.GetXmlContent("http://www.ban-centar.hr/xml/codelist/areaintervallist");

            var elementList = xmlContent.Elements();
            var areas = new List<Area>();
            foreach (var interval in elementList)
            {
                var area = new Area()
                {
                    Id = Convert.ToInt32(interval.Element("id").Value),
                    Name = interval.Element("name").Value
                };
                areas.Add(area);
            }

            return areas;
        }

        public static List<Floor> GetFloors()
        {
            var xmlContent = XmlHelper.GetXmlContent("http://www.ban-centar.hr/xml/codelist/floorlist");

            var elementList = xmlContent.Elements();
            var floors = new List<Floor>();
            foreach (var interval in elementList)
            {
                var floor = new Floor()
                {
                    Id = Convert.ToInt32(interval.Element("id").Value),
                    Name = interval.Element("name").Value
                };
                floors.Add(floor);
            }

            return floors;
        }
    }
}